<template>
  <transition name="fade-transform" mode="out-in">
    <keep-alive :include="catchList">
      <router-view :key="key" />
    </keep-alive>
  </transition>
</template>

<script>
export default {
  name: 'AppMain',
  computed: {
    key() {
      return this.$route.path
    },
    catchList() {
      const visitedViews = this.$store.state.tagsView.visitedViews
      if (Array.isArray(visitedViews)) {
        return visitedViews.filter((n) => n.name).map((m) => m.name)
      } else {
        return []
      }
    }
  }
}
</script>

<style lang="scss" scoped>
/* fade */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.28s;
}

.fade-enter,
.fade-leave-active {
  opacity: 0;
}

/* fade-transform */
.fade-transform-leave-active,
.fade-transform-enter-active {
  transition: all 0.4s;
}

.fade-transform-enter {
  opacity: 0;
  transform: translateX(-30px);
}

.fade-transform-leave-to {
  opacity: 0;
  transform: translateX(30px);
}
</style>
